<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>计算100以内自然数的和</title>
<script>
  function sum(m, n) {
    var result = 0;
    while (m <= n) {
      result = result + m;
      m++;
    }
    return result;
  }
  document.write(sum(1, 100));
</script>
</head>
<body>
</body>
</html>